﻿using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Enums;
using Newtonsoft.Json;

namespace Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes.DomainAttributes
{
    public class GPNumericDomainAttribute : AbstractIDomain
    {
        public GPNumericDomainAttribute(string allowempty = null, string low = null, string high = null, string json = null)
        {
            this.allowempty = allowempty;
            if(string.IsNullOrEmpty(low))
            this.Low = JsonConvert.DeserializeObject<Low>(low);
            if (string.IsNullOrEmpty(high))
                this.High = JsonConvert.DeserializeObject<High>(high);

            if (!string.IsNullOrEmpty(json))
            {
                var self = JsonConvert.DeserializeObject<GPNumericDomainAttribute>(json);
                this.allowempty = self.allowempty;
                this.Low=self.Low;
                this.High=self.High;
            }

        }

        public override DomainEnum type { get; set; } = DomainEnum.GPNumericDomain;

        public string allowempty { get; set; } = "false";

        public Low Low { get; set; }

        public High High { get; set; }
    }
    public class Low
    {
        public string Inclusive { get; set; }

        public string Val { get; set; }
    }

    public class High
    {
        public string Allow { get; set; }

        public string Val { get; set; }
    }
}
